﻿/**
 * Peter
 * Created by: Peter Development Team
 *    http://peter.codeplex.com/
 * 
 * GNU General Public License version 2 (GPLv2)
 *    http://peter.codeplex.com/license
 *
 *  This code is provided on an AS IS basis, with no WARRANTIES,
 *  CONDITIONS or GUARANTEES of any kind.
 *  
 **/

using System.ComponentModel.Composition;
using System.Threading.Tasks;
using Peter.Common;
using Peter.Common.Interfaces;
using Peter.Common.MainMenu;

namespace Peter.Net
{
   /// <summary>
   /// A project type for a solution.
   /// </summary>
   [Export (typeof (IPeterProjectType))]
   public class SolutionProjectType : IPeterProjectType
   {
      /// <summary>
      /// Gets the name of the project.
      /// </summary>
      public string Name
      {
         get { return ".Net Solution"; }
      }

      /// <summary>
      /// Gets the icon for the given project.
      /// </summary>
      public MainMenuIcon Icon
      {
         get { return MainMenuIcon.Csharp; }
      }

      /// <summary>
      /// Gets the project group this type is associated with.
      /// </summary>
      public string ProjectGroup
      {
         get { return ".Net"; }
      }

      /// <summary>
      /// Creates a project for this project type.
      /// </summary>
      /// <param name="projectName">Name of project to create.</param>
      /// <param name="projectLocation">Location of new project.</param>
      public void Create (string projectName, string projectLocation) { }

      /// <summary>
      /// Opens the project at the given path.
      /// </summary>
      /// <param name="projectPath">Path of project to open.</param>
      /// <returns>The opened project.</returns>
      public async Task<PeterProjectItem> Open (string projectPath)
      {
         var project = new SolutionProject (projectPath);
         return await project.Open () ? project : null;
      }

      /// <summary>
      /// Checks to see if this project type owns the given project.
      /// </summary>
      /// <param name="projectType">Name of project type.</param>
      /// <returns>True if owner of project type, otherwise false.</returns>
      public bool OwnsProject (string projectType)
      {
         return projectType == typeof (SolutionProject).ToString ();
      }
   }
}
